<meta charset="UTF-8">
<?php
require ('./lib/init.php');
//生成随机文件名
$fname = rand(10000,99999);

//获取文件后缀

$ext = strrchr($_FILES['pic']['name'],'.');//.jpg

//链接创建目录
$path = ROOT . '/upload/' . date('Y/m/d');
if (!is_dir($path)){
    mkdir( $path,0777,true);
}
echo move_uploaded_file($_FILES['pic']['tmp_name'],  $path . '/' . $fname . $ext)?'ok':'fail';
?>
